﻿@using Abp.Collections.Extensions
@using Partner.Surround.Web.Views
@using Partner.Surround.Web.Views.Shared.Components.SideBarNav
@model SideBarNavViewModel
@{
    var calculateMenuUrl = new Func<string, string>((url) =>
    {
        if (string.IsNullOrEmpty(url))
        {
            return ApplicationPath;
        }

        if (UrlChecker.IsRooted(url))
        {
            return url;
        }

        return ApplicationPath + url;
    });
}

<div class="left-nav">
    <div id="side-nav">
        <ul id="nav">
            @foreach (var menuItem in Model.MainMenu.Items)
            {
                <li>
                    @if (menuItem.Items.IsNullOrEmpty())
                    {
                        <a onclick="xadmin.add_tab('@menuItem.DisplayName','@calculateMenuUrl(menuItem.Url)')">
                            <i class="iconfont">@Html.Raw(menuItem.Icon)</i>
                            <cite>@menuItem.DisplayName</cite>
                        </a>
                    }
                    else
                    {
                        <a href="javascript:;">
                            <i class="iconfont left-nav-li" lay-tips="@menuItem.DisplayName">@Html.Raw(menuItem.Icon)</i>
                            <cite>@menuItem.DisplayName</cite>
                            <i class="iconfont nav_right">&#xe697;</i>
                        </a>
                        <ul class="sub-menu">
                            @foreach (var subMenuItem in menuItem.Items)
                            {
                                <li>
                                    @if (subMenuItem.Items.IsNullOrEmpty())
                                    {
                                        <a onclick="xadmin.add_tab('@subMenuItem.DisplayName','@calculateMenuUrl(subMenuItem.Url)')">
                                            <i class="iconfont">@Html.Raw(subMenuItem.Icon)</i>
                                            <cite>@subMenuItem.DisplayName</cite>
                                        </a>
                                    }
                                    else
                                    {
                                        <a href="javascript:;">
                                            <i class="iconfont">@Html.Raw(menuItem.Icon)</i>
                                            <cite>@subMenuItem.DisplayName</cite>
                                            <i class="iconfont nav_right">&#xe697;</i>
                                        </a>
                                        <ul class="sub-menu">
                                            @foreach (var subSubMenuItem in subMenuItem.Items)
                                            {
                                                <li>
                                                    <a onclick="xadmin.add_tab('@subSubMenuItem.DisplayName','@calculateMenuUrl(subSubMenuItem.Url)')">
                                                        <i class="iconfont">@Html.Raw(menuItem.Icon)</i>
                                                        <cite>@subSubMenuItem.DisplayName</cite>
                                                    </a>
                                                </li>
                                            }
                                        </ul>
                                    }
                                </li>
                            }
                        </ul>
                    }
                </li>
            }
        </ul>
    </div>
</div>
